from faker import Faker
import hashlib
import random

fake = Faker(locale='zh_CN')
# 生成 500 个用户数据
users = []
for i in range(1, 501):
    username = f"username={fake.user_name()}"
    password = f"{fake.password(length=12)}"
    password_md5 = f"password={hashlib.md5(password.encode('utf-8')).hexdigest()}"
    bankcard1 = "cardbank=中国建设银行&type=2&cardnum=123456789452131222"
    bankcard2 = "cardbank=中国农商银行&type=2&cardnum=123456789452131222"
    bankcard3 = "cardbank=中国工商银行&type=2&cardnum=123456789452131222"
    bankcard4 = "cardbank=中国交通银行&type=2&cardnum=123456789452131222"
    users.append(f"{username}&{password_md5};{bankcard1};{bankcard2};{bankcard3};{bankcard4}")
# 写入 TXT 文件（每行存储一个用户数据）
with open("users.txt", "w") as f:
    for user in users:
        f.write(f"{user}\n")
print("用户数据已生成到 users.txt")
